package com.mz.mattress.admin.service.impl;

import com.mz.mattress.admin.mapper.SysParamMapper;
import com.mz.mattress.admin.service.SysParamService;
import com.mz.mattress.api.common.Result;
import com.mz.mattress.api.entity.SysParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

@Slf4j
@Service
public class SysParamServiceImpl implements SysParamService {

    @Autowired
    private SysParamMapper sysParamMapper;

    @Override
    public SysParam getSysParam(String key) {
        return sysParamMapper.selectByParamKey(key);
    }

    @Override
    public Result<List<SysParam>> list() {
        List<SysParam> list = sysParamMapper.list();
        return Result.ok(list);
    }

    @Override
    public Result<SysParam> getById(Integer id) {
        SysParam sysParam = sysParamMapper.selectById(id);
        return Result.ok(sysParam);
    }

    @Override
    public Result add(SysParam sysParam) {
        sysParamMapper.insert(sysParam);
        return Result.ok();
    }

    @Override
    public Result updateById(SysParam sysParam) {
        sysParamMapper.updateById(sysParam);
        return Result.ok();
    }

    @Override
    public Result deleteByIds(Set<Integer> ids) {
        sysParamMapper.deleteBatchIds(ids);
        return Result.ok();
    }

}
